< previous page page_620 next page >

Page 620
8160-0620a.gif
Figure 30.5
A toolbar built at runtime.
On this form, you wont find an ImageList control, and at design time, the toolbar will look empty. Youre going to pass in the ImageList control from the previous form. In most of the applications I develop, I want to have just one central repository for all my toolbar images. As a result, I end up passing an ImageList control from my main MDI form to all the child forms that need one. You can accomplish this by using a Property Set procedure and a module-level variable on each form that needs an ImageList. Heres an example:
9f31265bb40b592b1929e18a47ab28e5.gif
Private milsList As ImageList

Property Set PImageList(ilsList As ImageList)
   Set milsList = ilsList
End Property
By using a Property Set procedure, you can pass an ImageList control form one form to another:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdToolRun_Click()
   With frmToolbarRunTime
      Set .PImageList = ilsList
      .Show
   End With
End Sub
Assuming you have an ImageList control called ilsList on the form from which this code is invoked, you can set the PImageList property on the form where you need the ImageList control to go. The sample that goes with this chapter is not an MDI application; this is just something you might want to do in your applications.
After youve set this property and invoke the Show method on the form, the code in the Form_Load event sets the toolbars ImageList property to the module-level reference to the ImageList control:

 
< previous page page_620 next page >

If you like this book, buy it!